package me.xcmc.org;

import me.xcmc.org.command.Cmd;
import me.xcmc.org.events.PlayerEvent;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.util.List;
import java.util.Objects;


public class StarsItem extends JavaPlugin {
    public static String prefix;
    public static File config;
    public static FileConfiguration cc;
    public static String a;
    public static String b;
    public static File item;
    public static FileConfiguration it;
    @Override
    public void onEnable() {
        onMessage();
        LoadConfig();
        getServer().getPluginManager().registerEvents(new PlayerEvent(),this);
        Objects.requireNonNull(getServer().getPluginCommand("starsitem")).setExecutor(new Cmd());
        int pluginId = 17449; // <-- Replace with the id of your plugin!
        Metrics metrics = new Metrics(this, pluginId);
        Bukkit.getConsoleSender().sendMessage("   _____ _                 _____ _                 ");
        Bukkit.getConsoleSender().sendMessage("  / ____| |               |_   _| |                ");
        Bukkit.getConsoleSender().sendMessage(" | (___ | |_ __ _ _ __ ___  | | | |_ ___ _ __ ___  ");
        Bukkit.getConsoleSender().sendMessage("  \\___ \\| __/ _` | '__/ __| | | | __/ _ \\ '_ ` _ \\ \n");
        Bukkit.getConsoleSender().sendMessage("  ____) | || (_| | |  \\__ \\_| |_| ||  __/ | | | | |");
        Bukkit.getConsoleSender().sendMessage(" |_____/ \\__\\__,_|_|  |___/_____|\\__\\___|_| |_| |_|");
        Bukkit.getConsoleSender().sendMessage("§f| §a插件作者: §4Xing_Chen");
        Bukkit.getConsoleSender().sendMessage("§f| §a插件版本: §d1.0.0");
        Bukkit.getConsoleSender().sendMessage("§f| §c本插件已受到著作权保护法的保护 - 任何侵权行为将会使用法律武器维权");
        Bukkit.getConsoleSender().sendMessage("§f+--------------------------------------------------------------------+");

    }

    @Override
    public void onDisable() {

    }
    public void LoadConfig(){
        config = new File(getDataFolder(),"config.yml");
        if (!config.exists()){
            saveResource("config.yml",false);
        }
        cc = YamlConfiguration.loadConfiguration(config);

        item = new File(getDataFolder(),"item.yml");
        if (!item.exists()){
            saveResource("item.yml",false);
        }
        it = YamlConfiguration.loadConfiguration(item);
    }
    public void onMessage(){
        prefix = getConfig().getString("prefix");
        a = getConfig().getString("a");
        b = getConfig().getString("b");
    }
}